// 生成token
const SECRET = 'nikanwoniubibu';
const jwt = require('jsonwebtoken');

module.exports = {
    getUserIdByjwtVerify(token, sucess, failed) {
        let userId = '';
        try {
            const tokenPass = jwt.verify(token, SECRET);
            userId = tokenPass.id;
            if (userId && sucess instanceof Function) { sucess(userId) };
        } catch (error) {
            console.log("token 过期！");
            if (failed instanceof Function) { failed(false) };
        }
    },
    SECRET
}

    